home *** CD-ROM | disk | FTP | other *** search
- /* FileCancel.c: Cancelation utility routine for ProjectDrag.
- *
- * A set of applets for drag and drop source control by Tim Maroney.
- * See develop, issue 23 for details.
- *
- * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
- * and using the MoreFiles utilities by Jim Luther.
- *
- * This software is free, but don't modify and redistribute it without
- * changing the status window to indicate your name and your changes!
- */
-
-
- #include <Errors.h>
-
- #include "SourceServer.h"
- #include "TasksAndErrors.h"
- #include "FileCancel.h"
-
-
- OSErr FileCancel(FSSpec *file, CKIDHandle theCKID)
- {
- Str255 projectName;
- AEDesc command;
- OSErr err;
-
- if ((*theCKID)->modifyReadOnly)
- {
- /* MRO -- orphan & create a CheckOut command for SourceServer
- * OrphanFiles <file>
- * CheckOut -y -d <dir> -project <project> <file>
- */
-
- /* mount the project */
- err = MountProjectFromCKID(theCKID, projectName);
- if (err != noErr) return err;
-
- /* orphan the file */
- err = CreateCommand(&command, "OrphanFiles");
- if (err == noErr)
- err = AddFileNameArg(&command, file);
- if (err != noErr)
- {
- AEDisposeDesc(&command);
- RaiseErrorNumber(err);
- return err;
- }
- err = SendCommand(&command);
- if (err != noErr) return err;
-
- /* create the checkout command */
- err = CreateCommand(&command, "CheckOut");
- if (err == noErr)
- err = AddPStringArg(&command, "\p-y");
- if (err == noErr)
- err = AddDirArg(&command, file->vRefNum, file->parID);
- if (err == noErr)
- err = AddProjectArg(&command, projectName);
- if (err == noErr)
- err = AddPStringArg(&command, file->name);
- if (err != noErr)
- {
- AEDisposeDesc(&command);
- RaiseErrorNumber(err);
- return err;
- }
-
- err = SendCommand(&command);
- if (err == noErr)
- SetFileLabel(file, 6, NULL); /* modify the label to red (6) */
- return err;
- }
- else
- {
- /* checked out for modify -- create a CheckOut -cancel command for SourceServer
- * CheckOut -cancel -y -d <dir> -project <project> <file>
- */
-
- /* mount the project */
- err = MountProjectFromCKID(theCKID, projectName);
- if (err != noErr) return err;
-
- err = CreateCommand(&command, "CheckOut");
- if (err == noErr)
- err = AddCStringArg(&command, "-cancel");
- if (err == noErr)
- err = AddCStringArg(&command, "-y");
- if (err == noErr)
- err = AddDirArg(&command, file->vRefNum, file->parID);
- if (err == noErr)
- err = AddProjectArg(&command, projectName);
- if (err == noErr)
- err = AddPStringArg(&command, file->name);
- if (err != noErr)
- {
- AEDisposeDesc(&command);
- RaiseErrorNumber(err);
- return err;
- }
-
- err = SendCommand(&command);
- if (err == noErr)
- SetFileLabel(file, 6, NULL); /* modify the label to red (6) */
- return err;
- }
- }
-